#!/bin/bash
#

cd /usr/local/src/LAMP/apache2.4/
tar -xf apr-1.4.5.tar.gz 
tar -xf apr-util-1.3.12.tar.gz 
unzip pcre-8.10.zip 
tar -xf httpd-2.4.41.tar.gz 
tar -xf php-7.1.32.tar.gz 
tar -xf amqp-1.9.3.tgz 
tar -xf memcache7.0.tar.gz 

cd apr-1.4.5
./configure --prefix=/usr/local/apr && make && make install 
cd ..

cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install 
cd ..

cd pcre-8.10
./configure --disable-shared --with-pic --prefix=/usr/local/pcre 
make && make install 
cd ..

cd httpd-2.4.41
./configure --prefix=/usr/local/apache2.4.41 --with-apr-util=/usr/local/apr-util/ --with-apr=/usr/local/apr  --with-pcre=/usr/local/pcre/  --enable-mods-shared=most  --enable-so  --enable-rewrite --enable-ssl  --with-mpm=prefork
make
make install 
cd ..

cd php-7.1.32
./configure --prefix=/usr/local/php7.1 --with-apxs2=/usr/local/apache2.4.41/bin/apxs --with-config-file-path=/usr/local/php7.1/etc --with-mysql --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-system --enable-inline-optimization --with-curl --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd-native-ttf --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magi
make
make test
make install 
cd ..

cd amqp-1.9.3
/usr/local/php7.1/bin/phpize 
./configure --with-php-config=/usr/local/php7.1/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.7.1/
make
make test
make install 
cd ..

cd memcache7
/usr/local/php7.1/bin/phpize 
./configure --with-php-config=/usr/local/php7.1/bin/php-config 
make
make test
make install 
cd ..

cd /usr/local/src/LAMP/apache2.4/php-7.1.32
cp php.ini-development /usr/local/php7.1/etc/php.ini
cd /usr/local/php7.1/etc/
echo "" >> ./php.ini
echo "" >> ./php.ini
echo "/usr/local/php7.1/lib/php/extensions/no-debug-non-zts-20160303/amqp.so" >> ./php.ini
echo "/usr/local/php7.1/lib/php/extensions/no-debug-non-zts-20160303/memcache.so" >> ./php.ini